import {UserProfilesAPI} from '@/request/api'
export default {
    namespaced: true,
    state: {
        cartTotal: '0',
        userInfo: {
            nickName: '--',
            coin: '-- ',
            headImg: require('../../assets/img/service.848ec511.png')
        },

    },
    mutations: {
        UpdateUserInfo(state, payload) {
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        initUserInfo(state) {
            state.cartTotal = '0',
            state.userInfo = {
                    nickName: '--',
                    coin: '--',
                    headImg: require('../../assets/img/userImg.f8bbec5e.png')
                }
        }
    },
    actions: {
        async asyncUpdateUserInfo(contxt) {
            let res = await UserProfilesAPI();
            contxt.commit('UpdateUserInfo', res.data)
        }
    }
}